<?php
namespace RMD\AccountBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;

use Symfony\Component\Validator\Mapping\ClassMetadata;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;

use RMD\AccessBundle\Entity\User;

class Campaign
{
	private $id;
	private $user_id;	
	private $title;
	private $fromName;
	private $replyAddress;
	private $description;
	private $dateCreated;
	private $dateSent;
	private $template_id;
	private $segment_id;	

	protected $user;
	protected $template;
	protected $segment;

	public function __construct() {

	}

	public static function loadValidatorMetadata(ClassMetadata $metadata)
    {
        $metadata->addConstraint(new UniqueEntity(array('fields' => array('title'))));
		$metadata->addPropertyConstraint('title', new NotBlank());
        $metadata->addPropertyConstraint('title', new Length(array("max" => 50)));
		
		$metadata->addPropertyConstraint('from', new NotBlank());		
        $metadata->addPropertyConstraint('from', new Length(array("max" => 101)));
		
		$metadata->addPropertyConstraint('replyAddress', new NotBlank());		
        $metadata->addPropertyConstraint('replyAddress', new Length(array("max" => 101)));
    }
 
	public function isOwnedBy(User $user) {
		if ($this->user_id == $user->getId()) {
			return true;
		}
		return false;
	}

    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set user_id
     *
     * @param integer $userId
     * @return Campaign
     */
    public function setUserId($userId)
    {
        $this->user_id = $userId;
    
        return $this;
    }

    /**
     * Get user_id
     *
     * @return integer 
     */
    public function getUserId()
    {
        return $this->user_id;
    }

    /**
     * Set title
     *
     * @param string $title
     * @return Campaign
     */
    public function setTitle($title)
    {
        $this->title = $title;
    
        return $this;
    }

    /**
     * Get title
     *
     * @return string 
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set fromName
     *
     * @param string $fromName
     * @return Campaign
     */
    public function setFromName($fromName)
    {
        $this->fromName = $fromName;
    
        return $this;
    }

    /**
     * Get fromName
     *
     * @return string 
     */
    public function getFromName()
    {
        return $this->fromName;
    }

    /**
     * Set replyAddress
     *
     * @param string $replyAddress
     * @return Campaign
     */
    public function setReplyAddress($replyAddress)
    {
        $this->replyAddress = $replyAddress;
    
        return $this;
    }

    /**
     * Get replyAddress
     *
     * @return string 
     */
    public function getReplyAddress()
    {
        return $this->replyAddress;
    }

    /**
     * Set description
     *
     * @param string $description
     * @return Campaign
     */
    public function setDescription($description)
    {
        $this->description = $description;
    
        return $this;
    }

    /**
     * Get description
     *
     * @return string 
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     * Set dateCreated
     *
     * @param \DateTime $dateCreated
     * @return Campaign
     */
    public function setDateCreated($dateCreated)
    {
        $this->dateCreated = $dateCreated;
    
        return $this;
    }

    /**
     * Get dateCreated
     *
     * @return \DateTime 
     */
    public function getDateCreated()
    {
        return $this->dateCreated;
    }

    /**
     * Set dateSent
     *
     * @param \DateTime $dateSent
     * @return Campaign
     */
    public function setDateSent($dateSent)
    {
        $this->dateSent = $dateSent;
    
        return $this;
    }

    /**
     * Get dateSent
     *
     * @return \DateTime 
     */
    public function getDateSent()
    {
        return $this->dateSent;
    }

    /**
     * Set template_id
     *
     * @param integer $templateId
     * @return Campaign
     */
    public function setTemplateId($templateId)
    {
        $this->template_id = $templateId;
    
        return $this;
    }

    /**
     * Get template_id
     *
     * @return integer 
     */
    public function getTemplateId()
    {
        return $this->template_id;
    }

    /**
     * Set segment_id
     *
     * @param integer $segmentId
     * @return Campaign
     */
    public function setSegmentId($segmentId)
    {
        $this->segment_id = $segmentId;
    
        return $this;
    }

    /**
     * Get segment_id
     *
     * @return integer 
     */
    public function getSegmentId()
    {
        return $this->segment_id;
    }

    /**
     * Set segment
     *
     * @param \RMD\AccountBundle\Entity\Segment $segment
     * @return Campaign
     */
    public function setSegment(\RMD\AccountBundle\Entity\Segment $segment = null)
    {
        $this->segment = $segment;
    
        return $this;
    }

    /**
     * Get segment
     *
     * @return \RMD\AccountBundle\Entity\Segment 
     */
    public function getSegment()
    {
        return $this->segment;
    }

    /**
     * Set user
     *
     * @param \RMD\AccessBundle\Entity\User $user
     * @return Campaign
     */
    public function setUser(\RMD\AccessBundle\Entity\User $user = null)
    {
        $this->user = $user;
    
        return $this;
    }

    /**
     * Get user
     *
     * @return \RMD\AccessBundle\Entity\User 
     */
    public function getUser()
    {
        return $this->user;
    }
}